package com.zenithmind.chat.enums;

/**
 * AI 模型类型枚举
 */
public enum ModelType {
    OPENAI(1, "OpenAI"),
    OLLAMA(2, "Ollama"),
    AZURE(3, "Azure OpenAI"),
    ANTHROPIC(4, "Anthropic"),
    CUSTOM_API(5, "自定义API");
    
    private final Integer code;
    private final String desc;
    
    ModelType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    
    public Integer getCode() {
        return this.code;
    }
    
    public String getDesc() {
        return this.desc;
    }
    
    /**
     * 通过代码获取枚举
     */
    public static ModelType getByCode(Integer code) {
        if (code == null) {
            return null;
        }

        for (ModelType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }

    /**
     * 通过代码获取枚举，如果不存在则抛出异常
     */
    public static ModelType fromCode(Integer code) {
        ModelType modelType = getByCode(code);
        if (modelType == null) {
            throw new IllegalArgumentException("不支持的模型类型代码: " + code);
        }
        return modelType;
    }
} 